<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
// import globalUploader from "@/components/globalUploader";
import {
  _getBaseInfo
} from "@/service/api/user";

export default {
  async created() {
    let theme = localStorage.getItem('theme')
    let style = localStorage.getItem('layoutColor')
    let res = await _getBaseInfo()
    if(res && res.status) {
      if(theme != res.data.theme || style !=res.data.style) {
        localStorage.setItem('theme',res.data.theme)
        localStorage.setItem('layoutColor',res.data.style)
        this.setTheme()
      }
    }else {
      this.setTheme()
    }
    
  },
  methods:{
    setTheme() {
        // window.location.reload()
        let theme = localStorage.getItem('theme')
        console.log(theme)
        let layoutColor = localStorage.getItem('layoutColor')
        if(theme === 'button_green') {
          require('./theme/theme-green.css')
        }
        if(theme === 'button_purple'){
          require('./theme/theme-purple.css')
        }
        if(layoutColor === '1' && theme === 'button_green') {
          require('@/styles/dark-header-green.scss')
        }
        if(layoutColor === '1' && theme === 'button_purple') {
          require('@/styles/dark-header-purple.scss')
        }
        if(layoutColor === '1' && (theme == 'button_blue' || theme == null)) {
          require('@/styles/dark-header-blue.scss')
        }
        if(layoutColor === '2') {
          require('@/styles/dark-sidebar.scss')
        }
    }
  },
  mounted() {
    document.getElementById("app__wrap__loading").style.display = "none";
  }
};
</script>
